# ifndef MODE
# define MODE

# include <tpl_dlist.H>
# include <tpl_dynSetTree.H>

# include <iostream>


/**************** Algoritmo de calculo de moda basado en árbol ****************/
// Clave para guardar en el árbol
struct Number_With_Frequency_Mode
{
  float n;
  float f;

  Number_With_Frequency_Mode(){}

  Number_With_Frequency_Mode(int _n) : n(_n), f(0){}
};

struct CmpMode
{
  bool operator()(const Number_With_Frequency_Mode & e1, const Number_With_Frequency_Mode & e2)
  {
    return e1.n < e2.n;
  }
};

struct OpMode
{
  Number_With_Frequency_Mode __nf;

  OpMode(const Number_With_Frequency_Mode & _nf) : __nf(_nf)
  {
    // Empty
  }

  void operator()(Number_With_Frequency_Mode & nf)
  {
     // Si la frecuencia actual es mayor a la que se consideraba mayor, la actual pasa a ser la mayor
     if (nf.f > __nf.f)
       {
         __nf.f = nf.f;
         __nf.n = nf.n;
       }
  }
};

# endif